package com.buanalintas.sandals.pos.suppliermodel;
import com.buanalintas.bynga.Dictionary;
import com.buanalintas.bynga.Field;
import com.buanalintas.bynga.Page;
import com.buanalintas.sandals.pos.entities.PosMasterSupplierModel;

public class SupplierModel extends Page {

    private Field supplierModelId;
    private Field supplierModelSupplierId;
    private Field supplierModelModelId;
    private Field supplierModelCode;

    public SupplierModel() {
        setTheClass(PosMasterSupplierModel.class);

        supplierModelId = new Field();
        supplierModelId.setName("supplierModelId");
        supplierModelId.setCaption("id");
        supplierModelId.setListProperties(" align=\"right\" width=\"5%\" nowrap");
        supplierModelId.setInputProperties(" size=\"10\"");
        getFields().add(supplierModelId);

        supplierModelCode = new Field();
        supplierModelCode.setName("supplierModelCode");
        supplierModelCode.setCaption("code");
        supplierModelCode.setInputProperties(" ");
        supplierModelCode.setRequired(true);
        supplierModelCode.setListProperties(" align=\"center\" width=\"10%\" nowrap");
        supplierModelCode.setInputType(" size=\"5\"");
        supplierModelCode.setInputCase(Field.CASE_UPPER);
        getFields().add(supplierModelCode);

        supplierModelSupplierId = new Field();
        supplierModelSupplierId.setName("supplierModelSupplierId");
        supplierModelSupplierId.setCaption("Supplier");
        supplierModelSupplierId.setInputProperties(" ");
        supplierModelSupplierId.setRequired(true);
        supplierModelSupplierId.setListProperties(" align=\"left\" width=\"40%\" nowrap");
        supplierModelSupplierId.setInputType(Field.INPUT_COMBO_BOX);
        getFields().add(supplierModelSupplierId);

        supplierModelModelId = new Field();
        supplierModelModelId.setName("supplierModelModelId");
        supplierModelModelId.setCaption("Model");
        supplierModelModelId.setInputProperties(" ");
        supplierModelModelId.setRequired(true);
        supplierModelModelId.setListProperties(" align=\"left\" width=\"40%\" nowrap");
        supplierModelModelId.setInputType(Field.INPUT_COMBO_BOX);
        getFields().add(supplierModelModelId);
        fillFields();

        getFieldsUnique().add(new Field[]{supplierModelCode});
        getFieldsAdd().remove(supplierModelId);
        getFieldsEdit().remove(supplierModelId);
        getFieldsList().remove(supplierModelId);
        
        setExportList(getClass().getResourceAsStream("SupplierModelList.jasper"));
        setExport(getClass().getResourceAsStream("SupplierModel.jasper"));
        getController().setOrder(supplierModelCode);
    }

    @Override
    public void beforeView() {
        beforeList();
    }

    @Override
    public void beforeExport() {
        getExportParams().put("title", Dictionary.getValue(this, "supplier"));
    }

    @Override
    public void beforeExportMulti() {
        beforeExport();
    }
}
